//index.js
//获取应用实例
const app = getApp()

// 引入SDK核心类
var QQMapWX = require('../../libs/qqmap-wx-jssdk.js');

// 实例化API核心类
var qqmapsdk = new QQMapWX({
  key: '6CMBZ-4HMKS-HUYO6-6CKQ2-SDR2K-UFB3M'
});

Page({
  data: {
    site: '',
    name:''
  },
  getSite() {
    let that = this
    wx.getLocation({
      type: 'wgs84',
      success: (res) => {
        const latitude = res.latitude
        const longitude = res.longitude
        // console.log(res)
        qqmapsdk.reverseGeocoder({
          location: {
            latitude, //纬度
            longitude //经度
          },
          success: (res) => {
            let site = res.result.ad_info.name.split(',').slice(1).join(' ')
            that.setData({
              site
            })

            wx.chooseLocation({
              success:(res)=>{
                that.setData({
                  name : res.address
                })  
              }
            })
          }
        })
      }
    })


  },
  onLoad: function () {

  },
})